package com.foreveredu.erlms.persist.hibernate;

import java.util.List;

import com.foreveredu.erlms.domain.Department;
import com.foreveredu.erlms.domain.User;
import com.foreveredu.erlms.persist.IDepartmentDao;

public class HibernateDepartmentDao extends HibernateAbstractDao<Department, Integer>
		implements IDepartmentDao {

	private static final long serialVersionUID = 1L;

	public HibernateDepartmentDao() {
		super(Department.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Department findDepartmentByDeptId(String deptId) {
		List<Department> deptList = this.getHibernateTemplate().find("from Department department where department.deptId = ?", deptId);
		Department dept = null;
		if (deptList != null && deptList.size() > 0) {
			dept = deptList.get(0);
		}
		return dept;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Department findDeptId(int deptid) {
		List<Department> deptList = this.getHibernateTemplate().find("from Department department where department.id = ?", deptid);
		Department dept = null;
		if (deptList != null && deptList.size() > 0) {
			dept = deptList.get(0);
		}
		return dept;
	}
	
}
